import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/home/index.vue'
import FooterCom from '@/components/FooterCom.vue'
import Video from '@/views/video/videoView.vue'
import Message from '@/views/message/messageView.vue'
import Detail from '@/views/detail/index.vue'
import MyLogin from '@/views/login/index.vue'
import searchView from '@/views/search/routerView.vue'
import Tourism from '@/views/tourism/tourismView.vue'
import hotelView from '@/views/hotel/hotelView.vue'
//@ts-ignore
import Mapa from '@/views/tourismmap/index.vue'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      meta: {
        hidden: true
      },
      components: {
        default: Home,
        FooterCom
      },
    },
    {
      path: '/home',
      name: 'homeview',
      meta: {
        hidden: true
      },
      components: {
        default: searchView,
        FooterCom
      },
      children: [
        {
          path: 'search',
          name: 'search',
          meta: {
            hidden: false
          },
          component: () => import('@/views/search/searchView.vue')
        }
      ]
    },
    {
      path: '/video',
      name: 'video',
      meta: {
        hidden: true
      },
      components: {
        default: Video,
        FooterCom
      },
      redirect: '/video/videoindex',
      children: [
        {
          path: 'videoindex',
          name: 'videoindex',
          component: () => import('@/views/video/index.vue')
        },
        {
          path: 'follow',
          name: 'follow',
          component: () => import('@/views/video/focusContent.vue')
        },
        {
          path: 'famous',
          name: 'famous',
          component: () => import('@/views/video/famousContent.vue')
        },
      ]
    },
    {
      path: '/message',
      name: 'message',
      meta: {
        hidden: true
      },
      components: {
        default: Message,
        FooterCom
      },
      redirect: '/message/mian',
      children: [
        {
          path: 'mian',
          name: 'mian',
          component: () => import('@/views/message/index.vue')
        },
        {
          path: 'chat',
          name: 'chat',
          meta: {
            hidden: false
          },
          component: () => import('@/views/message/messageChat.vue')
        }
      ]
    },
    {
      path: '/mylogin',
      name: 'mylogin',
      components: {
        default: MyLogin,
        FooterCom
      },
      redirect: '/mylogin/mymainlogin',
      children: [
        {
          path: 'mymainlogin',
          name: 'mymainlogin',
          meta: {
            hidden: true
          },
          component: () => import('@/views/login/my.vue')
        },
        {
          path: 'mycode',
          name: 'mycode',
          meta: {
            hidden: false
          },
          component: () => import('@/views/login/mycode.vue')
        },
        {
          path: 'mypassword',
          name: 'mypassword',
          meta: {
            hidden: false
          },
          component: () => import('@/views/login/mypassword.vue')
        },
        {
          path: 'mychat',
          name: 'mychat',
          meta: {
            hidden: false
          },
          component: () => import('@/views/login/mychat.vue')
        },
        {
          path: 'set',
          name: 'set',
          meta: {
            hidden: false
          },
          component: () => import('@/views/login/set.vue')
        }, {
          path: 'gold',
          name: 'gold',
          meta: {
            hidden: false
          },
          component: () => import('@/views/goldcoin/index.vue')
        }, {
          path: 'order',
          name: 'order',
          meta: {
            hidden: false
          },
          component: () => import('@/views/order/index.vue')
        },
        {
          path: 'release',
          name: 'release',
          meta: {
            hidden: false
          },
          component: () => import('@/views/release/index.vue')
        },
        {
          path: 'feedback',
          name: 'feedback',
          meta: {
            hidden: false
          },
          component: () => import('@/views/feedback/index.vue')
        },
        {
          path: 'fans',
          name: 'fans',
          meta: {
            hidden: false
          },
          component: () => import('@/views/fans/index.vue')
        },
      ]
    },
    {
      path: '/detail',
      name: 'detail',
      component: Detail
    },
    {
      path: '/tourism',
      name: 'tourism',
      component: Tourism,
      redirect: '/tourism/index',
      children: [
        {
          path: 'index',
          name: 'index',
          component: () => import('@/views/tourism/index.vue')
        },
        {
          path: 'tourismdetail',
          name: 'tourismdetail',
          component: () => import('@/views/tourism/detail.vue')
        }
      ]
    },
    {
      path: '/map',
      name: 'map',
      component: Mapa
    },
    {
      path: '/hotel',
      name: 'hotel',
      component: hotelView,
      redirect: '/hotel/hotelindex',
      children: [
        {
          path: 'hotelindex',
          name: 'hotelindex',
          component: () => import('@/views/hotel/index.vue')
        },
        {
          path: 'hoteldetail',
          name: 'hoteldetail',
          component: () => import('@/views/hotel/detail.vue')
        }
      ]
    },

  ],
})


//做权限使用
// router.beforeEach((to, from, next) => {

//   if (to.name == 'home') {
//     if (localStorage.getItem('isstate') != 'true') {
//       next('/mylogin/mymainlogin')
//     } else {
//       next()
//     }
//   } else if (to.name == 'homeview') {
//     if (localStorage.getItem('isstate') != 'true') {
//       next('/mylogin/mymainlogin')
//     } else {
//       next()
//     }
//   } else if (to.name == 'video') {
//     if (localStorage.getItem('isstate') != 'true') {
//       next('/mylogin/mymainlogin')
//     } else {
//       next()
//     }
//   } else {
//     next()
//   }
// })

export default router
